package com.lindenvalley.ch.content;

import java.io.IOException;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

public class User implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 2826394575175712763L;
	private int userId;
	private String userName;
	private String userLogin;
	private String userDisplayName;
	private short userLevel;
	private String userEmail;
	private String sessionId;
	private String branche;
	private String address;
	private String completeTask;
	private String birthDay;
	private String userAvatar;
	private transient Bitmap userAvatarBitmap;
	private String startUp;
	private String[] mondayWeek;
	private int reminder;
	private int Day;
	private int Hour;
	private int Minutes;

	public static final String COMPLETE_WEEK = "week";
	public static final String COMPLETE_DAY = "day";

	public int getUserId() {
		return userId;
	}

	public void setuserID(String userId) {
		try {
			this.userId = Integer.valueOf(userId);
		} catch (NumberFormatException ex) {
			ex.printStackTrace();
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setuserName(String userName) {
		this.userName = userName;
	}

	public String getUserLogin() {
		return userLogin;
	}

	public void setuserLogin(String userLogin) {
		this.userLogin = userLogin;
	}

	public String getUserDisplayName() {
		return userDisplayName;
	}

	public void setuserDisplayName(String userDisplayName) {
		this.userDisplayName = userDisplayName;
	}

	public short getUserLevel() {
		return userLevel;
	}

	public void setuserLevel(String userLevel) {
		try {
			this.userLevel = Short.valueOf(userLevel);
		} catch (NumberFormatException ex) {
			ex.printStackTrace();
		}
	}

	public void setuserLevel(short userLevel) {
		this.userLevel = userLevel;
	}

	public String getUserEmail() {
		return userEmail;
	}

	public void setuserEmail(String userEmail) {
		this.userEmail = userEmail;
	}

	public String getSessionId() {
		return sessionId;
	}

	public void setsessionId(String sessionId) {
		this.sessionId = sessionId;
	}

	public String getBranche() {
		return branche;
	}

	public void setbranche(String branche) {
		this.branche = branche;
	}

	public String getAddress() {
		return address;
	}

	public void setaddress(String address) {
		this.address = address;
	}

	public String getCompleteTask() {
		return completeTask;
	}

	public void setcompleteTask(String completeTask) {
		this.completeTask = completeTask;
	}

	public String getBirthDay() {
		return birthDay;
	}

	public void setbday(String birthDay) {
		this.birthDay = birthDay;
	}

	public String getUserAvatar() {
		return userAvatar;
	}

	public void setuserAvatar(String userAvatar) {
		this.userAvatar = userAvatar;
		try {
			URL avatarUrl = new URL(this.userAvatar);
			userAvatarBitmap = BitmapFactory.decodeStream(avatarUrl
					.openStream());
		} catch (MalformedURLException ex) {
			ex.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			// e.printStackTrace();
		}
	}

	public void setUserAvatarBitmap(Bitmap userAvatarBitmap) {
		this.userAvatarBitmap = userAvatarBitmap;
	}

	public Bitmap getUserAvatarBitmap() {
		return userAvatarBitmap;
	}

	public void setStartUp(String startUp) {
		this.startUp = startUp;
	}

	public String getStartUp() {
		return startUp;
	}

	public void setMondayWeek(String mondayWeek) {
		this.mondayWeek = mondayWeek.split(",");
	}
	
	public String getMondayWeek(int weekNumber){
		String result = null;
		if (this.mondayWeek != null)
			try{
				result = mondayWeek[weekNumber];
			}catch (ArrayIndexOutOfBoundsException ex){
				ex.printStackTrace();
			}
		return result;
	}

	public void setDay(String day) {
		try{
			Day = Integer.parseInt(day);
		} catch (NumberFormatException ex){
			
		} catch (NullPointerException ex){
			
		}
		
	}

	public int getDay() {
		return Day;
	}

	public void setHour(String hour) {
		try{
			Hour = Integer.parseInt(hour);
		} catch (NumberFormatException ex){
			
		} catch (NullPointerException ex){
			
		}		
	}

	public int getHour() {
		return Hour;
	}

	public void setMinutes(String minutes) {
		try{
			Minutes = Integer.parseInt(minutes);
		} catch (NumberFormatException ex){
			
		} catch (NullPointerException ex){
			
		}
	}

	public int getMinutes() {
		return Minutes;
	}

	/**
	 * @param reminder the reminder to set
	 */
	public void setreminder(int reminder) {
		this.reminder = reminder;
	}

	/**
	 * @return the reminder
	 */
	public int getReminder() {
		return reminder;
	}


}
